﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.CodeDom;
using Microsoft.CSharp;
using System.CodeDom.Compiler;
using System.IO;
using System.Diagnostics;
using System.Reflection;
using BMC.ARSystem;
using System.Collections;
using System.Text.RegularExpressions;

namespace NRemedy.Test
{
    [TestClass]
    public class CodeGenerate
    {
        [TestMethod]
        public void Test_Generate_()
        {
            CSharpModelGenerateCode cmg = new CSharpModelGenerateCode();
            CSharpModelGeneratorDefaultFactoryForTest cmdgdf = new CSharpModelGeneratorDefaultFactoryForTest();
            ARSchemaForTest asrsch = new ARSchemaForTest();
            CodeCompileUnit ccu = cmg.GenerateClassByFormName(asrsch, "MyModelTest", cmdgdf);

            CSharpCodeProvider cprovider = new CSharpCodeProvider();//提供对 C# 代码生成器和代码编译器的实例的访问
            ICodeGenerator gen = cprovider.CreateGenerator();//C# 代码生成器的实例。
            
            ICodeCompiler compiler = cprovider.CreateCompiler();//C# 代码编译器的实例。
            //CS代码文件的字符串
            StringBuilder fileContent = new StringBuilder();
            using (StringWriter sw = new StringWriter(fileContent))
            {
                gen.GenerateCodeFromCompileUnit(ccu, sw, new CodeGeneratorOptions());//主要是想把生成的代码保存为cs文件
            }

            //在编译时候需要的编译参数
            string str = System.Environment.CurrentDirectory;
            string filePath = str + @"\GenerateTest.dll";//生成cs文件的保存位置
            CompilerParameters cp = new CompilerParameters();
            cp.ReferencedAssemblies.Add("System.dll");
            cp.ReferencedAssemblies.Add(@"BMC.ARSystem.dll");
            cp.ReferencedAssemblies.Add(@"NRemedy.dll");
            cp.OutputAssembly = filePath;//输出dll的位置
            cp.GenerateInMemory = true; //是否只在内存中生成
            cp.IncludeDebugInformation = true;//包含调试符号  pdb文件
            cp.GenerateExecutable = false;//生成dll,不是exe 
            cp.WarningLevel = 4;//获取或设置使编译器中止编译的警告级别。
            cp.TreatWarningsAsErrors = false;
            File.WriteAllText(filePath, fileContent.ToString());
            File.WriteAllText(str + @"\GenerateTest.txt", fileContent.ToString());
            CompilerResults cr = compiler.CompileAssemblyFromFile(cp, filePath); 
            //CompilerResults cr = cprovider.CompileAssemblyFromFile(cp, filePath);
            String outputMessage = "";
            foreach (string item in cr.Output)
            {
                outputMessage += item + Environment.NewLine;//调试的最终输出信息
            }
            if (cr.Errors.Count > 0)//有编译错误就抛出异常
            {
                throw new Exception("error:" + Environment.NewLine + outputMessage);
            }
            Assembly a = Assembly.LoadFile(filePath);
            Type[] types = Assembly.LoadFile(filePath).GetTypes();

            Type type1 = types[0];
            Assert.AreEqual<string>(type1.Name, "MyModelTest");
            object[] clsAttrs = type1.GetCustomAttributes(true);//Attributes
            Assert.AreEqual<int>(clsAttrs.Count(), 1);
            ARFormAttribute amAtr = clsAttrs[0] as ARFormAttribute;
            Assert.AreEqual<string>(amAtr.FormName, "MyModelTest");
            PropertyInfo[] pi1 = type1.GetProperties(BindingFlags.Instance | BindingFlags.Public);//属性
            Assert.AreEqual<string>(pi1[0].Name, "DiaryFieldGet");
            Assert.AreEqual<string>(pi1[1].Name, "DiaryFieldSet");
            Assert.AreEqual<string>(pi1[2].Name, "CharacterField");
            Assert.AreEqual<string>(pi1[3].Name, "SelectionField");
            Assert.AreEqual<string>(pi1[4].Name, "CharacterField2");
            object[] proAttrs1 = pi1[0].GetCustomAttributes(true);//Attributes
            Assert.AreEqual<int>(proAttrs1.Count(), 1);
            ARFieldAttribute adAtr1 = proAttrs1[0] as ARFieldAttribute;
            Assert.AreEqual<string>(adAtr1.BinderAccess.ToString(), "OnlyBind");
            Assert.AreEqual<string>(adAtr1.DatabaseID.ToString(), "1001");
            Assert.AreEqual<string>(adAtr1.DatabaseName.ToString(), "DiaryField");
            Assert.AreEqual<string>(adAtr1.DataType.ToString(), "DiaryField");
            object[] proAttrs2 = pi1[1].GetCustomAttributes(true);//Attributes
            Assert.AreEqual<int>(proAttrs2.Count(), 1);
            ARFieldAttribute adAtr2 = proAttrs2[0] as ARFieldAttribute;
            Assert.AreEqual<string>(adAtr2.BinderAccess.ToString(), "OnlyUnBind");
            Assert.AreEqual<string>(adAtr2.DatabaseID.ToString(), "1001");
            Assert.AreEqual<string>(adAtr2.DatabaseName.ToString(), "DiaryField");
            Assert.AreEqual<string>(adAtr2.DataType.ToString(), "DiaryField");
            object[] proAttrs3 = pi1[2].GetCustomAttributes(true);//Attributes
            Assert.AreEqual<int>(proAttrs3.Count(), 1);
            ARFieldAttribute adAtr3 = proAttrs3[0] as ARFieldAttribute;
            Assert.AreEqual<string>(adAtr3.DatabaseID.ToString(), "1002");
            Assert.AreEqual<string>(adAtr3.DatabaseName.ToString(), "CharacterField");
            Assert.AreEqual<string>(adAtr3.DataType.ToString(), "CharacterField");
            object[] proAttrs4 = pi1[3].GetCustomAttributes(true);//Attributes
            Assert.AreEqual<int>(proAttrs4.Count(), 1);
            ARFieldAttribute adAtr4 = proAttrs4[0] as ARFieldAttribute;
            Assert.AreEqual<string>(adAtr4.DatabaseID.ToString(), "1003");
            Assert.AreEqual<string>(adAtr4.DatabaseName.ToString(), "SelectionField");
            Assert.AreEqual<string>(adAtr4.DataType.ToString(), "SelectionField");

            object[] proAttrs5 = pi1[4].GetCustomAttributes(true);//Attributes
            Assert.AreEqual<int>(proAttrs5.Count(), 1);
            ARFieldAttribute adAtr5 = proAttrs5[0] as ARFieldAttribute;
            Assert.AreEqual<string>(adAtr5.DatabaseID.ToString(), "1004");
            Assert.AreEqual<string>(adAtr5.DatabaseName.ToString(), "CharacterField2");
            Assert.AreEqual<string>(adAtr5.DataType.ToString(), "CharacterField");
            Assert.AreEqual<string>(adAtr5.BinderAccess.ToString(), "OnlyUnBind");

            Type type2 = types[1];
            Assert.AreEqual<string>(type2.Name, "SelectionField_Enum");
            Assert.AreEqual<bool>(type2.IsEnum, true);
            string[] names = Enum.GetNames(type2);
            Assert.AreEqual<string>(names[0], "aa");
            Assert.AreEqual<string>(names[1], "bb");



        }
    }

    internal class ARSchemaForTest : IARSchema
    {
        public IEnumerable<ARForm> GetListForm()
        {

            return null;
        }

        public IEnumerable<ARForm> GetListForm(ARFormFilterDelegate formFilter)
        {
            return null;
        }

        public IEnumerable<Field> GetListField(string formName)
        {
            return null;
        }

        public IEnumerable<Field> GetListField(string formName, ARFieldFilterDelegate fieldFilter)
        {
            List<Field> fieldList = new List<Field>();
            DiaryField diary = new DiaryField();
            diary.Name = "DiaryField";
            diary.Id = 1001;
            fieldList.Add(diary);

            CharacterField character = new CharacterField();
            character.Name = "CharacterField";
            character.Id = 1002;
            fieldList.Add(character);

            SelectionField select = new SelectionField();
            select.Name = "SelectionField";
            select.Id = 1003;
            fieldList.Add(select);

            CharacterField character2 = new CharacterField();
            character2.Name = "CharacterField2";
            character2.Id = 1004;
            character2.FieldOption = Constants.AR_FIELD_OPTION_DISPLAY;
            fieldList.Add(character2);

            return fieldList;
        }
    }

    internal class CSharpModelGeneratorDefaultFactoryForTest : CSharpModelGeneratorDefaultFactory
    {
        public override IGenerateNameResolver CreateGenerateNameResolver()
        {
            return new GenerateNameResolverForTestDF();
        }

        public override IGenerateRootNamespace CreateGenerateRootNamespace()
        {
            return new GenerateRootNamespaceForTestDF();
        }

        public override IGenerateImportNamespace CreateGenerateImportNamespace()
        {
            return new GenerateImportNamespaceForTestDF();
        }

        public override IGenerateClass CreateGenerateClass()
        {
            return new GenerateClassForTestDF();
        }

        public override IGenerateClassAttribute CreateGenerateClassAttribute()
        {
            return new GenerateClassAttributeForTestDF();
        }

        public override IGenerateFieldFactory CreateGenerateFieldFactory()
        {
            return new GenerateFieldFactoryForTestDF();
        }

        public override IGeneratePropertyFactory CreateGeneratePropertyFactory()
        {
            return new GeneratePropertyFactoryForTestDF();
        }

        public override IGeneratePropertyAttribute CreateGeneratePropertyAttribute()
        {
            return new GeneratePropertyAttributeForTestDF();
        }

        public override IGetGenerateFieldDelegate CreateGenerateFieldDelegate()
        {
            return new GetGenerateFieldDelegateForTest();
        }

        public override IGetGeneratePropertyDelegate CreateGeneratePropertyDelegate()
        {
            return new GetGeneratePropertyDelegateForTestDF();
        }

        public override IGetARFieldFilterDelegate CreateGetARFieldFilterDelegate()
        {
            return new GetARFieldFilterDelegateForTestDF();
        }
    }

    internal class GenerateNameResolverForTestDF : IGenerateNameResolver
    {
        public virtual string DefaultClassNameResolver(string formName)
        {
            return Regex.Replace(formName, @"[^\w]+", "");
        }

        public virtual string DefaultFieldNameResolver(string fieldName)
        {
            return "_" + Regex.Replace(fieldName, @"[^\w]+", "");
        }

        public virtual string DefaultPropertyNameResolver(string fieldName)
        {
            return Regex.Replace(fieldName, @"[^\w]+", "");
        }


        //Custom Selection Type Name for AR Selection Type
        public virtual string SelectionTypeResolver(string fieldName)
        {
            return Regex.Replace(fieldName, @"[^\w]+", "") + "_Enum";
        }

        //Custom DiaryFieldGet Name for AR Diary Type
        public virtual string DiaryFieldNameGetResolver(string fieldName)
        {
            return "_" + Regex.Replace(fieldName, @"[^\w]+", "") + "Get";
        }

        //Custom DiaryFieldNameSet Name for AR Diary Type
        public virtual string DiaryFieldNameSetResolver(string fieldName)
        {
            return "_" + Regex.Replace(fieldName, @"[^\w]+", "") + "Set";
        }

        //Custom PropertyNameGet Name for AR Diary Type
        public virtual string DiaryPropertyNameGetResolver(string fieldName)
        {
            return Regex.Replace(fieldName, @"[^\w]+", "") + "Get";
        }

        //Custom PropertyNameSet Name for AR Diary Type
        public virtual string DiaryPropertyNameSetResolver(string fieldName)
        {
            return Regex.Replace(fieldName, @"[^\w]+", "") + "Set";
        }
    }

    internal class GenerateRootNamespaceForTestDF : IGenerateRootNamespace
    {
        public void Create(CodeCompileUnit codeCompileUnit)
        {
            codeCompileUnit.Namespaces.Add(new CodeNamespace("NRemedy"));
        }
    }

    internal class GenerateImportNamespaceForTestDF : IGenerateImportNamespace
    {
        public void Create(CodeNamespace rootNamespace)
        {
            rootNamespace.Imports.Add(new CodeNamespaceImport("System"));
            rootNamespace.Imports.Add(new CodeNamespaceImport("NRemedy"));
            rootNamespace.Imports.Add(new CodeNamespaceImport("BMC.ARSystem"));
        }
    }

    internal class GenerateClassForTestDF : IGenerateClass
    {
        public void Create(CodeNamespace rootNamespace, string className, string formName, IGenerateClassAttribute attributeGenerator)
        {
            CodeTypeDeclaration classType = new CodeTypeDeclaration("MyModelTest");
            classType.BaseTypes.Add(new CodeTypeReference("ARBaseForm"));
            //-----changed by parker,change above code
            //-----since issue Id #9742 【NRemedy】Defect for ARRegularForm
            //-----ARRegularForm should be dropped.
            //-----and the code generation should generate all property
            classType.Attributes = MemberAttributes.Public;
            Dictionary<string, object> _attributeProperties = new Dictionary<string, object>();
            attributeGenerator.Create(classType, typeof(ARFormAttribute), _attributeProperties);
            rootNamespace.Types.Add(classType);
        }
    }

    internal class GenerateClassAttributeForTestDF : IGenerateClassAttribute
    {
        public void Create(CodeTypeDeclaration classType, Type attributeType, Dictionary<string, object> properties)
        {
            CodeTypeReference _attributeType = new CodeTypeReference(attributeType);
            CodeAttributeDeclaration _cad = new CodeAttributeDeclaration(_attributeType);
            CodeAttributeArgument _arg = new CodeAttributeArgument("FormName", new CodePrimitiveExpression("MyModelTest"));
            _cad.Arguments.Add(_arg);
            classType.CustomAttributes.Add(_cad);
        }
    }

    internal class GenerateFieldFactoryForTestDF : IGenerateFieldFactory
    {
        public IGenerateField getGenerateFieldCreate(ARType arType)
        {
            if (arType == ARType.SelectionField)
            {
                return new GenerateSelectionFieldForTestDF();
            }
            else if (arType == ARType.DiaryField)
            {
                return new GenerateDiaryFieldForTestDF();
            }
            else
            {
                return new GenerateFieldForTestDF();
            }
        }
    }

    internal class GenerateSelectionFieldForTestDF : IGenerateField
    {
        public void Create(CodeTypeDeclaration classType, string fieldName, string fieldType, string propertyName, GenerateFieldDelegate fieldDelegate)
        {
            string _fieldName = "_SelectionField";
            string _typeName = "SelectionField_Enum";
            CodeMemberField _field = new CodeMemberField();
            _field.Name = _fieldName;
            _field.Type = new CodeTypeReference(_typeName);
            _field.Attributes = MemberAttributes.Private | MemberAttributes.Final;
            classType.Members.Add(_field);
        }
    }

    internal class GenerateDiaryFieldForTestDF : IGenerateField
    {
        public void Create(CodeTypeDeclaration classType, string fieldName, string fieldType, string propertyName, GenerateFieldDelegate fieldDelegate)
        {
            string _fieldNameSet = "_DiaryFieldSet";
            string _fieldNameGet = "_DiaryFieldGet";
            CodeMemberField _field = new CodeMemberField();
            _field.Name = _fieldNameSet;
            _field.Type = new CodeTypeReference("String");
            _field.Attributes = MemberAttributes.Private | MemberAttributes.Final;
            classType.Members.Add(_field);

            CodeMemberField _field2 = new CodeMemberField();
            _field2.Name = _fieldNameGet;
            _field2.Type = new CodeTypeReference("BMC.ARSystem.DiaryList");
            _field2.Attributes = MemberAttributes.Private | MemberAttributes.Final;
            classType.Members.Add(_field2);

        }
    }

    internal class GenerateFieldForTestDF : IGenerateField
    {
        public void Create(CodeTypeDeclaration classType, string fieldName, string fieldType, string propertyName, GenerateFieldDelegate fieldDelegate)
        {

            CodeMemberField _field = new CodeMemberField();
            _field.Name = fieldName;
            _field.Type = new CodeTypeReference("String");
            _field.Attributes = MemberAttributes.Private | MemberAttributes.Final;
            classType.Members.Add(_field);

        }
    }

    internal class GeneratePropertyFactoryForTestDF : IGeneratePropertyFactory
    {
        public IGenerateProperty getGeneratePropertyCreate(ARType arType)
        {
            if (arType == ARType.SelectionField)
            {
                return new GenerateSelectionPropertyForTestDF();
            }
            else if (arType == ARType.DiaryField)
            {
                return new GenerateDiaryPropertyForTestDF();
            }
            else
            {
                return new GeneratePropertyForTestDF();
            }
        }
    }

    internal class GenerateSelectionPropertyForTestDF : IGenerateProperty
    {
        public void Create(CodeTypeDeclaration classType, string propertyName, string propertyType, Limit limit, Dictionary<string, object> attributePropertyValues, GeneratePropertyDelegate propertyDelegate, IGeneratePropertyAttribute attributeGenerator)
        {
            CodeMemberProperty _property = new CodeMemberProperty();
            _property.Name = "SelectionField";
            string _propertyType = "SelectionField_Enum";
            _property.Type = new CodeTypeReference(_propertyType);
            _property.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            string fieldName = "_SelectionField";
            _property.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName)));
            _property.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName), new CodePropertySetValueReferenceExpression()));
            _property.SetStatements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "OnPropertyChanged"), new CodeExpression[] { new CodePrimitiveExpression(propertyName) }));
            //add attribute
            attributeGenerator.Create(_property, typeof(ARFieldAttribute), attributePropertyValues);
            classType.Members.Add(_property);
            //add enum
            CodeTypeDeclaration enCode = new CodeTypeDeclaration(_propertyType);
            enCode.IsEnum = true;
            enCode.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            CodeMemberField mem = new CodeMemberField(typeof(Int32), "aa");
            mem.Attributes = MemberAttributes.Public;
            mem.InitExpression = new CodeSnippetExpression("1");
            enCode.Members.Add(mem);
            CodeMemberField mem2 = new CodeMemberField(typeof(Int32), "bb");
            mem2.Attributes = MemberAttributes.Public;
            mem2.InitExpression = new CodeSnippetExpression("2");
            enCode.Members.Add(mem2);
            classType.Members.Add(enCode);
        }
    }

    internal class GenerateDiaryPropertyForTestDF : IGenerateProperty
    {
        public void Create(CodeTypeDeclaration classType, string propertyName, string propertyType, Limit limit, Dictionary<string, object> attributePropertyValues, GeneratePropertyDelegate propertyDelegate, IGeneratePropertyAttribute attributeGenerator)
        {
            //set
            string diarySetName = "DiaryFieldSet";
            CodeMemberProperty _propertyset = new CodeMemberProperty();
            _propertyset.Name = diarySetName;
            _propertyset.Type = new CodeTypeReference("String");
            _propertyset.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            string fieldNameset = "_DiaryFieldSet";
            _propertyset.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldNameset)));
            _propertyset.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldNameset), new CodePropertySetValueReferenceExpression()));
            _propertyset.SetStatements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "OnPropertyChanged"), new CodeExpression[] { new CodePrimitiveExpression(diarySetName) }));

            //get
            string diaryGetName = "DiaryFieldGet";
            CodeMemberProperty _propertyget = new CodeMemberProperty();
            _propertyget.Name = diaryGetName;
            _propertyget.Type = new CodeTypeReference("BMC.ARSystem.DiaryList");
            _propertyget.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            string fieldNameget = "_DiaryFieldGet";
            _propertyget.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldNameget)));
            _propertyget.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldNameget), new CodePropertySetValueReferenceExpression()));
            _propertyget.SetStatements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "OnPropertyChanged"), new CodeExpression[] { new CodePrimitiveExpression(diaryGetName) }));

            //add attribute
            if (attributePropertyValues.ContainsKey("BinderAccess"))
                attributePropertyValues["BinderAccess"] = ModelBinderAccessLevel.OnlyUnBind;
            else
                attributePropertyValues.Add("BinderAccess", ModelBinderAccessLevel.OnlyUnBind);
            attributeGenerator.Create(_propertyset, typeof(ARFieldAttribute), attributePropertyValues);

            if (attributePropertyValues.ContainsKey("BinderAccess"))
                attributePropertyValues["BinderAccess"] = ModelBinderAccessLevel.OnlyBind;
            else
                attributePropertyValues.Add("BinderAccess", ModelBinderAccessLevel.OnlyBind);
            attributeGenerator.Create(_propertyget, typeof(ARFieldAttribute), attributePropertyValues);

            classType.Members.Add(_propertyget);
            classType.Members.Add(_propertyset);
        }
    }

    internal class GeneratePropertyForTestDF : IGenerateProperty
    {
        public void Create(CodeTypeDeclaration classType, string propertyName, string propertyType, Limit limit, Dictionary<string, object> attributePropertyValues, GeneratePropertyDelegate propertyDelegate, IGeneratePropertyAttribute attributeGenerator)
        {

            CodeMemberProperty _property = new CodeMemberProperty();
            _property.Name = propertyName;
            _property.Type = new CodeTypeReference(propertyType);
            _property.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            string fieldName = "_" + propertyName;
            _property.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName)));
            _property.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName), new CodePropertySetValueReferenceExpression()));
            _property.SetStatements.Add(new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "OnPropertyChanged"), new CodeExpression[] { new CodePrimitiveExpression(propertyName) }));
            //add attribute
            attributeGenerator.Create(_property, typeof(ARFieldAttribute), attributePropertyValues);
            classType.Members.Add(_property);
        }
    }

    internal class GeneratePropertyAttributeForTestDF : IGeneratePropertyAttribute
    {
        public void Create(CodeMemberProperty propertyType, Type attributeType, Dictionary<string, object> properties)
        {
            CodeTypeReference _attributeType = new CodeTypeReference(attributeType);
            CodeAttributeDeclaration _cad = new CodeAttributeDeclaration(_attributeType);
            foreach (var propertry in properties)
            {
                object value = propertry.Value;
                CodeAttributeArgument _arg = null;
                if (value.GetType().IsEnum)
                    _arg = new CodeAttributeArgument(propertry.Key, new CodePropertyReferenceExpression(new CodeVariableReferenceExpression(value.GetType().Name), value.ToString()));
                else
                    _arg = new CodeAttributeArgument(propertry.Key, new CodePrimitiveExpression(propertry.Value));
                _cad.Arguments.Add(_arg);
            }
            propertyType.CustomAttributes.Add(_cad);
        }
    }

    internal class GetGenerateFieldDelegateForTest : IGetGenerateFieldDelegate
    {
        public GenerateFieldDelegate getGenerateFieldDelegate()
        {
            return new GenerateFieldDelegate(fieldDelegate);
        }

        private bool fieldDelegate(string fieldName)
        {
            return true;
        }
    }

    internal class GetGeneratePropertyDelegateForTestDF : IGetGeneratePropertyDelegate
    {
        public GeneratePropertyDelegate getGeneratePropertyDelegate()
        {
            return new GeneratePropertyDelegate(fieldDelegate);
        }

        private bool fieldDelegate(string propertyName)
        {
            return true;
        }
    }

    internal class GetARFieldFilterDelegateForTestDF : IGetARFieldFilterDelegate
    {
        public ARFieldFilterDelegate getARFieldFilterDelegate()
        {
            return new ARFieldFilterDelegate(filterIsDataFieldOrReservedField);
        }

        private bool filterIsDataFieldOrReservedField(BMC.ARSystem.Field field)
        {
            return true;
        }
    }
}
